<!--
 * @Author: zxh
 * @Email: 1271027008@qq.com
 * @Date: 2020-03-11 14:34:07
 * @Descripttion: 库房管理员管理
 -->

<div class="warehouseuser_manage">
    <div nz-row class="table_row_1" nzGutter="16">
        <div nz-col nzSpan="8">
            <nz-table nzTitle="库房管理员列表" nzSize="small" #smallTable [nzData]="listOfData" [nzFrontPagination]="false" [nzBordered]="true">
                <thead>
                    <tr>
                        <th>库管员名称</th>
                        <th>设置管理仓库</th>
                    </tr>
                </thead>
                <tbody>
                    <tr *ngFor="let data of smallTable.data">
                        <!-- <td>{{ data.username }}</td> -->
                        <td>{{ data.nickName }}</td>
                        <td>
                            <button nz-button
                                [class]="selectedManage==data.id?'ant-btn active':'ant-btn ant-btn-primary'"
                                (click)="selectMange(data.id)">选择仓库</button>
                        </td>
                    </tr>
                </tbody>
            </nz-table>
            <div nz-row class="row_2">
                <nz-pagination [(nzPageSize)]="pageSize" (nzPageIndexChange)="clickPageMange($event)"
                    [nzPageIndex]="currentManagePage" [nzTotal]="totalSizeManage" [nzShowTotal]="totalTemplate">
                </nz-pagination>
                <ng-template #totalTemplate let-total> 总共 {{totalSizeManage}} 条 </ng-template>
            </div>
        </div>
        <div nz-col nzSpan="16">
            <div nz-row class="row_3">
                <button *ngIf="power.add" nz-button nzType="" (click)="showModal(1)" [disabled]="isCanAddEdit"
                    [class]="isCanAddEdit?'ant-btn ant-btn-primary defaultAddBg disabledBg':'ant-btn ant-btn-primary defaultAddBg'">
                    <i nz-icon nzType="plus"></i>新增
                </button>
                <button *ngIf="power.edit" nz-button nzType="" (click)="showModal(2)" [disabled]="deleteManageCk.length !== 1"
                    [class]="deleteManageCk.length !== 1?'ant-btn ant-btn-primary defaultEditBg disabledBg':'ant-btn ant-btn-primary defaultEditBg'">
                    <i nz-icon nzType="edit"></i>修改
                </button>
                <button *ngIf="power.del" nz-button nzType="" (click)="deleteMoreManageCK()" [disabled]="deleteManageCk.length == 0"
                    [class]="deleteManageCk.length == 0?'ant-btn ant-btn-primary defaultDeleteBg disabledBg':'ant-btn ant-btn-primary defaultDeleteBg'">
                    <i nz-icon nzType="delete"></i>删除
                </button>
            </div>
            <div nz-row class="table_row_2">
                <nz-table #rowSelectionTableDetail nzTitle="仓库列表" [nzData]="listOfDataDetail" [nzFrontPagination]="false"
                    (nzCurrentPageDataChange)="currentPageDataChangeDetail($event)" [nzBordered]="true" nzSize="small" >
                    <thead>
                        <tr>
                            <th nzShowCheckbox [(nzChecked)]="isAllDisplayDataCheckedDetail"
                                [nzIndeterminate]="isIndeterminateDetail" (nzCheckedChange)="checkAllDetail($event)">
                            </th>
                            <th>库房名称</th>
                            <th>默认要料库房</th>
                            <th>库区名称</th>
                            <th>默认要料库区</th>
                           
                            <th>是否默认仓库</th>
                            <!-- <th>操作</th> -->
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor="let data of rowSelectionTableDetail.data">
                            <td nzShowCheckbox [(nzChecked)]="mapOfCheckedIdDetail[data.id]"
                                [nzDisabled]="data.disabled" (nzCheckedChange)="refreshStatusDetail()">
                            <td>{{ data.warehouseName }}</td>
                            <td>{{ data.toWarehouseName }}</td>
                            <td>{{ data.warehouseAreaName }}</td>
                            <td>{{ data.toWarehouseAreaName}}</td>
                            <td>{{ data.isDefault?'是':'否' }}</td>
                            <!-- <td>
                                <button style="margin-right:4px;" nz-button nzType="primary" (click)="showModal(2,data)"
                                    style="margin-right: 4px;"><i nz-icon nzType="edit"></i></button>
                                <button nz-button nzType="danger" (click)="deleteManageCK(data.id)"><i nz-icon
                                        nzType="delete"></i></button>
                            </td> -->
                        </tr>
                    </tbody>
                </nz-table>
                <div nz-row class="row_2">
                    <nz-pagination [(nzPageSize)]="pageSize" (nzPageIndexChange)="clickPageMangeCk($event)"
                        [nzPageIndex]="currentManageCKPage" [nzTotal]="totalSizeManageCK"
                        [nzShowTotal]="totalTemplateCK">
                    </nz-pagination>
                    <ng-template #totalTemplateCK let-total> 总共 {{totalSizeManageCK}} 条 </ng-template>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="modal_box"></div>
<nz-modal appDragModal nzMaskClosable="false" [nzGetContainer]="modalDomBox" class="modal" [(nzVisible)]="isVisible" [nzTitle]="modalType==1?'绑定仓库':'修改绑定仓库'" (nzOnCancel)="handleCancel()"
    [nzFooter]="null">
    <form nz-form [formGroup]="ckForm" (ngSubmit)="submitck()">
        <div nz-row nzGutter="16">
            <div nz-col nzSpan="12">
                <nz-form-item>
                    <nz-form-label [nzSpan]="11" nzRequired>选择库房</nz-form-label>
                    <nz-form-control [nzSpan]="13" nzErrorTip="请选择库房!">
                        <nz-select class="select_term" nzDropdownClassName="select_custom" formControlName="kfIdModal" (ngModelChange)="selectedKF($event)">
                            <nz-option *ngFor="let item of KFList" [nzValue]="item.id" [nzLabel]="item.name">
                            </nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="12">
                <nz-form-item>
                    <nz-form-label [nzSpan]="11">选择库区</nz-form-label>
                    <nz-form-control [nzSpan]="13">
                        <nz-select class="select_term" nzDropdownClassName="select_custom" formControlName="kqIdModal">
                            <nz-option *ngFor="let item of KQList" [nzValue]="item.id" [nzLabel]="item.name">
                            </nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
        </div>
        <div nz-row nzGutter="16">
            <div nz-col nzSpan="12">
                <nz-form-item>
                    <nz-form-label [nzSpan]="11">默认要料库房</nz-form-label>
                    <nz-form-control [nzSpan]="13">
                        <nz-select class="select_term" nzDropdownClassName="select_custom" formControlName="defaultKFIdModal"
                            (ngModelChange)="selectDefault($event)">
                            <nz-option *ngFor="let item of KFList" [nzValue]="item.id" [nzLabel]="item.name">
                            </nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="12">
                <nz-form-item>
                    <nz-form-label [nzSpan]="11">默认要料库区</nz-form-label>
                    <nz-form-control [nzSpan]="13">
                        <nz-select class="select_term" nzDropdownClassName="select_custom" formControlName="defaultKQIdModal">
                            <nz-option *ngFor="let item of defaultKQList" [nzValue]="item.id" [nzLabel]="item.name">
                            </nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
        </div>
        <div nz-row nzGutter="16">
            <div nz-col nzSpan="12">
                <nz-form-item>
                    <nz-form-label [nzSpan]="11">默认仓库</nz-form-label>
                    <nz-form-control [nzSpan]="13">
                        <nz-switch formControlName="isDefaultCK" nzCheckedChildren="是" nzUnCheckedChildren="否">
                        </nz-switch>
                    </nz-form-control>
                </nz-form-item>
            </div>
        </div>
        <div class="kf_modal_footer">
            <div style="text-align: right;">
                <button nz-button type="button" nzType="default" (click)="handleCancel()">取消</button>
                <button nz-button nzType="primary">确定</button>
            </div>
        </div>
    </form>
</nz-modal>